package com.linuxgt.android.layoutapp.service;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import android.util.Log;

import com.linuxgt.android.layoutapp.FrameLayoutActivity;
import com.linuxgt.android.layoutapp.R;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.assertEquals;

/**
 * Created by liute on 2017/5/15.
 */
@RunWith(AndroidJUnit4.class)
public class CarTest extends ActivityTestRule<FrameLayoutActivity> {
    private Car car;
    private Context context;
    private FrameLayoutActivity frameLayoutActivity;

    public CarTest() {
        super(FrameLayoutActivity.class);
    }

    @Test
    public void add() throws Exception {
        assertEquals(3,car.add(1,2));
        assertEquals("com.linuxgt.android.layoutapp",context.getPackageName());
        assertEquals("LayoutApp",context.getString(R.string.app_name));
        Log.i(getClass().getName(), context.getPackageName());
        Log.i(getClass().getName(), context.getString(R.string.app_name));
    }

    @Before
    public  void init() throws Exception{
        car = new Car();
        context = InstrumentationRegistry.getTargetContext();
        frameLayoutActivity = getActivity();
    }

}